package com.nanbei.recursion;

import java.util.LinkedList;

/**
 * @ClassDescription: 汉诺塔问题
 * @JdkVersion: 17
 * @Author: BaoShan.li
 * @Created: 2023/11/22 10:56
 */
public class HanoiTower {

    static LinkedList<Integer> a = new LinkedList<>();
    static LinkedList<Integer> b = new LinkedList<>();
    static LinkedList<Integer> c = new LinkedList<>();

    static void init(int n) {
        for (int i = n; i >= 1; i--) {
            a.add(i);
        }
    }

    static void h(int n , LinkedList<Integer> a,
                  LinkedList<Integer> b,LinkedList<Integer> c){
        if (n == 0){
            return;
        }

        h(n-1,a,c,b);
        c.addLast(a.removeLast());
        print();
        h(n-1,b,a,c);

    }

    private static void print() {
        System.out.println("-----------------------");
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
    }


}
